package com.yyplatform.admin.platform.role.model.entity;

import java.util.List;

import com.yyplatform.admin.platform.role.model.entity.converter.MenuParam;
import com.yyplatform.admin.platform.role.model.entity.converter.MenuParamConverter;
import com.yyplatform.admin.infra.model.entity.BaseEntity;

import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;

/**
 * Created on 2024-09-12
 */
@Entity
@Getter
@Setter
@Table(name = "sys_menu")
public class SysMenuEntity extends BaseEntity {

    @Column(name = "name", nullable = false, columnDefinition = " varchar(50) comment '菜单名称' ")
    private String name;

    @Column(name = "pid", nullable = false, columnDefinition = " bigint(20) comment '上级菜单ID' ")
    private Long pid;


    @Column(name = "order_num", nullable = false, columnDefinition = " int(5) comment '排序' ")
    private Integer orderNum;


    @Column(name = "menu_type", nullable = false, columnDefinition = " varchar(10) comment '菜单类型' ")
    private String menuType;

    @Column(name = "visible", nullable = false, columnDefinition = " tinyint(4) comment '菜单显示状态' ")
    private Boolean visible;


    @Column(name = "permissions", nullable = false, columnDefinition = " varchar(100) comment '【按钮】权限标识' ")
    private String permissions;

    @Column(name = "icon", nullable = false, columnDefinition = " varchar(50) comment '菜单图标' ")
    private String icon;

    @Column(name = "component",
            columnDefinition = " varchar(100) comment '组件路径（组件页面完整路径，相对于src/views/，缺省后缀 .vue）' ")
    private String component;

    @Column(name = "enabled", nullable = false, columnDefinition = " tinyint(1) comment '是否启用' ")
    private Boolean enabled;

    @Column(name = "keep_alive", nullable = false, columnDefinition = " tinyint(1) comment '【菜单】是否开启页面缓存' ")
    private Boolean keepAlive;

    @Column(name = "route_name", columnDefinition = " varchar(100) comment '路由名称（Vue Router "
            + "中用于命名路由）' ")
    private String routeName;

    @Column(name = "route_path", nullable = false, columnDefinition = " varchar(100) comment '路由路径（Vue Router 中定义的 "
            + "URL 路径）' ")
    private String routePath;

    @Column(name = "redirect", columnDefinition = " varchar(100) comment '重定向路径' ")
    private String redirect;


    @Column(name = "always_show",
            columnDefinition = " tinyint(1) comment '【目录】只有一个子路由是否始终显示 ' ")
    private Boolean alwaysShow;

    @Convert(converter = MenuParamConverter.class)
    @Column(name = "params", columnDefinition = " json comment '菜单参数（json 格式）' ")
    private List<MenuParam> params;

    @Column(name = "remark", columnDefinition = " varchar(255) comment '备注' ")
    private String remark;

}
